package com.zhiche.lisa.bms.controller.trans;


import com.zhiche.lisa.bms.dao.model.trans.TransTypeNameContrast;
import com.zhiche.lisa.bms.service.trans.TransTypeNameContrastService;
import com.zhiche.lisa.core.enums.CommonEnum;
import com.zhiche.lisa.core.supports.BaseException;
import com.zhiche.lisa.core.supports.RestfulResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 运输方式对照 前端控制器
 * </p>
 *
 * @author liuanshun
 * @since 2018-12-05
 */
@Controller
@RequestMapping("/transTypeNameContrast")
@Api(value = "/transTypeNameContrast", description = "运输方式对照接口", tags = {"运输方式对照接口"})
public class TransTypeNameContrastController {

    private final Logger LOGGER = LoggerFactory.getLogger(TransTypeNameContrastController.class);

    @Autowired
    private TransTypeNameContrastService transTypeNameContrastService;

    /**
     * 根据指定条件筛选运输方式对照信息
     *
     * @param condition
     * @return
     */
    @GetMapping(value = "/selectTransTypeNameList")
    @ApiOperation(value = "根据指定条件筛选运输方式对照信息", notes = "根据指定条件筛选运输方式对照信息", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiResponses({@ApiResponse(code = 0, message = "success", response = TransTypeNameContrast.class), @ApiResponse(code = -1, message = "系统异常")})
    public RestfulResponse<List<TransTypeNameContrast>> selectTransTypeNameList(@RequestBody Map<String, Object> condition) {
        LOGGER.info("/TransTypeNameContrastController.selectTransTypeNameList Param {} ", condition);
        RestfulResponse<List<TransTypeNameContrast>> restful = new RestfulResponse<>(CommonEnum.SUCCESS.getCode(), CommonEnum.SUCCESS.getText(), null);
        try {
            List<TransTypeNameContrast> transTypeNameContrasts = transTypeNameContrastService.selectTransTypeNameList(condition);
            restful.setData(transTypeNameContrasts);
        } catch (BaseException e) {
            LOGGER.error("/TransTypeNameContrastController.selectTransTypeNameList ERROR: {}", e.getMessage());
            restful = new RestfulResponse(CommonEnum.ERROR.getCode(), e.getMessage(), null);
        } catch (Exception e) {
            LOGGER.error("/TransTypeNameContrastController.selectTransTypeNameList ERROR: {}", e.getMessage());
            restful = new RestfulResponse(CommonEnum.ERROR.getCode(), CommonEnum.ERROR.getText(), null);
        }
        return restful;
    }
}

